﻿$(document).ready(function () {

    $(".share_table tr:last-child").addClass("fl_row");
    $(".share_area").last().removeClass("sha_bot_line");

    $('#userName').focus(function () {
        if (this.value == '用户名/Email') this.value = '';
    }).blur(function () {
        if (this.value == '') this.value = '用户名/Email';
    });

    $('#a_other_login').click(function () {
        return showDialog('/ucenter/otherlogin.aspx', 350, 520, '其他登录');
    });


    var rr = $("#seleMenu");
    var lis = rr.find("li.libg");

    lis.each(function () {
        var ls = $(this).find(".seleMenu");
        var lsH = ls.height() + 2;
        ls.find(".seleLay").height(lsH);

        ls.find("p").hover(function () {
            $(this).addClass("over");
        }, function () {
            $(this).removeClass("over");
        });
    });

    lis.hover(function () {
        var els = $(this);
        els.addClass("now");
        els.find(".seleMenu").show();
    }, function () {
        var els = $(this);
        els.removeClass("now");
        els.find(".seleMenu").hide();
    });

    $(document).ajaxStart(showAjaxLoading).ajaxStop(hideAjaxLoading);
    LoadSearch();

});


//onLoginSubmit(this),onLoginSubmit(this,'re_url')
function onLoginSubmit() {
    var form = $('#' + arguments[0]);
    var reUrl = (arguments.length > 1) ? arguments[1] : '';
    var t_username = $.trim($('#userName', form).val());
    var t_password = $.trim($('#password', form).val());
    if (t_username == "" || t_password == "") {
        alert('请输入用户名或密码');
    }
    else {
        $(form).ajaxSubmit({
            success: function (data) {
                if (data.success) {
                    if (reUrl != '') {
                        window.location = reUrl;
                    }
                    else {
                        window.location.reload(false);
                    }
                } else {
                    alert(data.error);
                }
            },
            url: "/UCenter/Ajax.ashx?a=log_u",
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            type: "post",
            dataType: "json",
            timeout: 60000
        });
    }
    return false;
}

function onLogoutSubmit() {
    $.post('/UCenter/Ajax.ashx?a=lou_u', { e: Math.random().toString() }, function (data) {
        if (data.success) {
            if (arguments.length == 1) {
                window.location = arguments[0];
            }
            else {
                window.location.reload(false);
            }
        } else {
            alert(data.error);
        }
    }, 'json');
}
function tcBoard(bid) {
    if ($('#' + bid).is(':visible')) {
        $('#' + bid + '_img').attr('src', '/templets/default/images/collapsed_yes.gif');
        $('#' + bid).hide();
    } else {
        $('#' + bid + '_img').attr('src', '/templets/default/images/collapsed_no.gif');
        $('#' + bid).show();
    }
}

function showAjaxLoading(){	
	$('#ajaxLoading').css({ 
		top: $(window).scrollTop() + 5 + 'px'
	}).show();
}

function hideAjaxLoading(){
	$('#ajaxLoading').hide();
}

/*
function userConfig(theType, theValue){
	$.post( '/ajax/config.aspx', { type: theType, value: theValue }, function(data) {
		if (data.success == 'true'){
			window.location.reload(false);
		}else{
			failureMessage(data.error);
		}
	}, 'json');
}
*/